﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SHDQGSWEB.Models
{
    public class DownloadRepository
    {
        SHDQGSDBDataContext db = new SHDQGSDBDataContext();
        public IQueryable<Download> FindAllDownloads()
        {
            return from download in db.Downloads
                   select download;
        }
        public Download FindDownload(int downloadId)
        {
            return db.Downloads.Single(p => p.DownloadId == downloadId);
        }
        public bool Add(Download download)
        {
            try
            {
                db.Downloads.InsertOnSubmit(download);
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public bool Delete(Download download)
        {
            try
            {
                db.Downloads.DeleteOnSubmit(download);
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }
        public bool Save()
        {
            try
            {
                db.SubmitChanges();
            }
            catch (Exception)
            {

                return false;
            }
            return true;
        }
    }
}